<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            X-admin v1.0
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/static/css/x-admin.css" media="all">
        <style>
            #upload_ul li {
                width: 80px;
                height: 60px;
                float: left;
                margin-left: 10px;
                margin-bottom: 10px;list-style-type: none;
            }
        </style>
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" action='<{:Url("admin/FoodCity/imgSort")}>' method="POST" >
                <input type="hidden" name="id" value="<{$foodCity.id}>">
                <div class="layui-form-item">
                    <label  class="layui-form-label">缩略图
                    </label>
                    <ul id="upload_ul">
                    {foreach $foodCity.imgUrl as $url}
                        <li>
                            <img id=""  width="80" src="<{$url}>">
                            <input type="hidden" name="imgUrl[]" class="hidImg"  value="<{$url}>">
                        </li>
                    {/foreach}
                    <!--<img id="LAY_demo_upload" width="400" src="/static/images/banner.png">-->
                    </ul>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">
                        保存
                    </button>
                </div>
            </form>
        </div>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/static/js/x-layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/jquery.min.js"></script>
        <script type="text/javascript" src="/static/js/jquery-migrate-1.1.1.js"></script>
        <script type="text/javascript" src="/static/js/jquery.dragsort-0.5.1.min.js"></script>
        <script>
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
                var form = layui.form()
                    ,layer = layui.layer;
                layui.upload({
                    url: '<{:Url("admin/FoodCity/upload")}>' //上传接口
                    ,success: function(data){ //上传成功后的回调
                        var i = 0;
                        for(i=0;i<data.length;i++){
                            console.log(data[i]);
                            $img = '<img id="" width="100" style="padding-left:5px" onclick="delImg(this, '+ data[i]['filepath'] +')" src="'+ data[i]['file_path'] +'">';
                            $hidImg = '<input type="hidden" name="imgUrl[]" class="hidImg" onclick="delImg(this, '+ data[i]['filepath'] +')" value="'+ data[i]['file_path'] +'">';

                            $('#LAY_demo_upload').append($img);
                            $('#hidenImage').append($hidImg);
                        }
                    },
                    error: function() {
                        console.log('error');
                    }
                });
            });
            // 图片拖动
            $(function() {
                try{
                    $("#upload_ul").dragsort({
                        dragSelector: "li",
                        dragBetween: true ,
                        dragEnd:function(){

                            console.log('此处可放拖动结束后的方法。')
                        }
                    });
                }catch(e){
                }
            });
        </script>
        <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
        </script>
    </body>

</html>